<template>
	<view class="content">
		<u-image :src="appletImgUrl+'invite-bg.png'" class="bg-img" width="375px" height="667px"></u-image>
		<view class="box-erweima">
			<view class="ad-text-box">
				<view class="ad-text-one">
					人脉就是钱脉
				</view>
				<view class="ad-text-two">
					“中盈联盟”邀请您来消费赚钱有财富
				</view>
			</view>
		</view>
		<view class="cash-code">
			<image class="container" :src="ewmImg"></image>
			<canvas class="canvas-code" canvas-id="myQrcode" style="
		      background: #fff;
		      width: 280px;
		      height: 280px;
		      display: block;
		      left: -800rpx;
		      position: absolute;
		    " />
		</view>
	</view>
</template>

<script>
	import QRCode from "@/utils/weapp-qrcode.js";
	import {
		appletImgUrl
	} from "@/common/config.js"
	import {
		getStoreData,
		setStoreData,
		httpPost,
		httpGet
	} from "@/utils/http.js";
	export default {

		data() {
			return {
				appletImgUrl: appletImgUrl,
				totalPromoteCount: 0,
				opacity: 0,
				imageURL: this.imageURL,
				loading: true,
				textObj: {
					color: '#ffffff'
				},
				background: {
					backgroundColor: 'transparent'
				},
				codeImg: this.imageURL + 'USER/5a7ec1ff-2d57-446a-ad37-ae134a8ca105.png',
				qrcodeSize: uni.upx2px(360),
				qrcodeSrc: '',
				dealNumber: 0,
				rule: '',
				ewmImg: "",
			};
		},
		onLoad() {
			this.getShare();
		},
		methods: {
			getCode(url) {
				new QRCode("myQrcode", {
					text: "https://www.chain-pay.cn?promoterUserId="+uni.getStorageSync("userInfo").userId,
					width: 280, //canvas 画布的宽
					height: 280, //canvas 画布的高
					padding: 16, // 生成二维码四周自动留边宽度，不传入默认为0
					correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度
					callback: (res) => {
						console.log(res)
						this.ewmImg = res.path;
					},
				});
			},
			getShare() {
				const _this = this;
				httpGet("/api/user/userShare/1")
					.then((res) => {
						console.log(res)
						const result = res.data.url;
						_this.getCode(result);
						
					})
					.catch((e) => {
						
					});
			},

		}
	}
</script>

<style lang="scss">
	

	.content {
		background: linear-gradient(-90deg, #f90, #f60);
		height: 100vh;
		position: relative;
		.box-erweima {
			position: absolute;
			top:440rpx;
			width: 100%;
			.ad-text-box{
				font-size: 40rpx;
				font-weight: bold;
				text-align: center;
				color: #fff;
			}
			
		}
		.cash-code{
			position: absolute;
			top:580rpx;
			width: 100%;
			display: flex;
			flex-direction: row;
			justify-content: center;
		}
		
		.container {
			width: 280px;
			height: 280px;
		}
	}
</style>